
using System;
using System.Collections.Generic;
using System.Text;
using DotNetNuke.Services.Scheduling;

namespace MailProcessing
{
    
    public class MailProcessingSchedule: SchedulerClient 
    {

        public MailProcessingSchedule(ScheduleHistoryItem oItem)
            : base()
        {
            this.ScheduleHistoryItem = oItem;
        }


        public override void DoWork()
        {
            try
            {
                //Perform required items for logging
                this.Progressing();

                //Your code goes here
                ApplicationFacade.GetInstance().ProcessingAllMailMessages();
                //To log note
                //this.ScheduleHistoryItem.AddLogNote("note")

                //Show success
                this.ScheduleHistoryItem.Succeeded = true;
            }
            catch (Exception ex)
            {
                this.ScheduleHistoryItem.Succeeded = false;
                this.Errored(ref ex);
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
    }
}
